#include "kill.h"
#include "config.h"

Kill::Kill()
{
    //骷颅头资源加载
    m_Coin.load(KILL_PATH);

    //骷颅头位置
    m_X = GAME_WIDTH;
    m_Y = 0;

    //骷颅头状态
    m_Free = true;

    //骷颅头速度
    m_Speed = KILL_SPEED;

    //骷颅头矩形框（碰撞检测）
    m_Rect.setWidth(m_Coin.width());
    m_Rect.setHeight(m_Coin.height());
    m_Rect.moveTo(m_X,m_Y);
}

void Kill::updatePosition()
{
    //空闲骷颅头不计算坐标
    if(m_Free)
    {
        return;
    }

    m_X -= m_Speed;
    m_Rect.moveTo(m_X,m_Y);

    //如果超出屏幕  重置空闲状态
    if(m_X <= -m_Rect.width())
    {
        m_Free = true;
    }
}
